﻿using System;

namespace CalmNine.Framework
{ 
    public interface IEventVal<T> : IEasyEvent
    {
        T Value { get; set; }
        void SetValueWithoutEvent(T newValue);

        /// <summary>
        /// 注册委托并自动执行
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        IUnRegister RegisterWithInit(Action<T> action);

        /// <summary>
        /// 移除委托
        /// </summary>
        /// <param name="onValueChanged"></param>
        void UnRegister(Action<T> onValueChanged);

        /// <summary>
        /// 注册委托函数
        /// </summary>
        /// <param name="onValueChanged"></param>
        /// <returns></returns>
        IUnRegister Register(Action<T> onValueChanged);
    }
}